package com.uzai.console.web.fd;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.fd.fdgoodspara.FdGoodsParaDto;
import com.uzai.console.dto.fd.fdgoodspara.FdGoodsParaPreviewDto;
import com.uzai.console.dto.fd.fdtemplate.FdTemplateDto;
import com.uzai.console.dto.fd.fdtemplate.FdTemplateIdDto;
import com.uzai.console.dto.fd.fdtemplate.FdTemplateQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.device.DeviceService;
import com.uzai.console.service.fd.FdTemplateService;
import com.uzai.console.vo.device.DeviceInfoVo;
import com.uzai.console.vo.fd.fdgoodspara.FdGoodsParaPreviewVo;
import com.uzai.console.vo.fd.fdtemplate.FdTemplateVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 发单模板
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "发单模板",tags = "个人微信|发单|发单模板")
@ApiSort(100)
@RestController
public class FdTemplateController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(FdTemplateController.class);

    @Autowired
    private FdTemplateService fdTemplateService;
    @Autowired
    private DeviceService deviceService;

    @ApiOperation(value = "分页查询发单模板列表", notes = "分页查询发单模板列表", response = FdTemplateVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/fdTemplate/findFdTemplateList")
    public Object findFdTemplateList(@RequestBody FdTemplateQuery fdTemplateQuery){
        return fdTemplateService.findFdTemplateList(fdTemplateQuery);
    }

    @SystemLogType(model = SystemModelEnum.FdTemplate, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加发单模板", notes = "添加发单模板")
    @ApiOperationSupport(order = 2)
    @PostMapping("/fdTemplate/addFdTemplate")
    public Object addFdTemplate(@RequestBody FdTemplateDto fdTemplateDto){
        fdTemplateService.addFdTemplate(fdTemplateDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.FdTemplate, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑发单模板", notes = "编辑发单模板" )
    @ApiOperationSupport(order = 3)
    @PostMapping("/fdTemplate/updateFdTemplate")
    public Object updateFdTemplate(@RequestBody FdTemplateDto fdTemplateDto){
        fdTemplateService.updateFdTemplate(fdTemplateDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.FdTemplate, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除发单模板", notes = "删除发单模板")
    @ApiOperationSupport(order = 4)
    @PostMapping("/fdTemplate/deleteFdTemplate")
    public Object deleteFdTemplate(@RequestBody FdTemplateIdDto fdTemplateIdDto){
        fdTemplateService.deleteFdTemplate(fdTemplateIdDto);
        return true;
    }

    @ApiOperation(value = "查询发单模板详情", notes = "查询发单模板详情", response = FdTemplateVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/fdTemplate/findFdTemplate")
    public Object findFdTemplate(@RequestBody FdTemplateIdDto fdTemplateIdDto){
        return fdTemplateService.findFdTemplate(fdTemplateIdDto);
    }

    @ApiOperation(value = "查询所有发单模板下拉列表", notes = "查询所有发单模板下拉列表", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/fdTemplate/findFdTemplateListByAll")
    public Object findFdTemplateListByAll(){
        FdTemplateQuery fdTemplateQuery = new FdTemplateQuery();
        fdTemplateQuery.setMerId(getLoginInfo().getMerId());
        return fdTemplateService.findFdTemplateListByAll(fdTemplateQuery);
    }

    @SystemLogType(model = SystemModelEnum.FdTemplate, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加商品变量", notes = "添加商品变量", response = String.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/fdTemplate/addFdGoodsPara")
    public Object addFdGoodsPara(@RequestBody FdGoodsParaDto fdGoodsParaDto){
        return fdTemplateService.addFdGoodsPara(fdGoodsParaDto);
    }

    @SystemLogType(model = SystemModelEnum.FdTemplate, type = OperationTypeEnum.QUERY)
    @ApiOperation(value = "预览商品", notes = "预览商品", response = String.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/fdTemplate/previewFdGoodsPara")
    public Object previewFdGoodsPara(@RequestBody FdGoodsParaPreviewDto fdGoodsParaPreviewDto){
        return fdTemplateService.previewFdGoodsPara(fdGoodsParaPreviewDto);
    }



}
